package edu.zut2.poly_demo;

public class Test3 {

    public static void main(String[] args) {

        Bird bird = new Ostrich("鸵鸟一号","灰色","运动");

        Bird bird2 = new Pigeon("鸽子一号","白色","送信");

        /**
         * bird指向具体的子类对象后，此时调用的fly是子类重写后的，不再是父类的
         */
        bird.fly();
        bird2.fly();

        Test3 test3 = new Test3();
        /**
         * 当一个方法的参数是一个引用数据类型并且是某些类的父类时，可以利用多态传参
         */
        test3.bird_fly(new Ostrich("鸵鸟一号","灰色","运动"));
        test3.bird_fly(bird2);

    }

    public void bird_fly(Bird bird){
        bird.fly();
    }

}
